#ifndef __FAT_H__
#define __FAT_H__

    #define FAT_CLUS_END                 0xFFFE
	#define FAT_CLUS_IDLE		         0xFFFF

	#define FAT_CLUS_ROOT		         0xFFF8
	
	#define FAT_ROOT_CLUS_ID0	         0
	#define FAT_ROOT_CLUS_ID1	         1
	
	#define FAT_RESERVED_NUM             2

    #define FAT_NUM1    				1
    #define FAT_NUM2    				2

	#define FAT_OK						0
	#define FAT_1_ERR					1
	#define FAT_2_ERR					2
	#define FAT_12_ERR					3
	
	extern void InitFAT(void);
	
	extern void InitFATCount(void);  

	extern UINT16 ReadFAT(UINT16 Index);
	extern void WriteFAT(UINT16 Index, UINT16 Value);
	
	extern UINT16 GetNextFAT(void);
	extern UINT16 GetFATTotal(void);
	extern UINT16 GetFATFree(void);

	extern void RecoverFAT(UINT16 DstNum); 
	extern void BackupFAT(void);
	extern UINT16 CheckFAT(void);

#endif
